﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace botliga
{
    public class BanList
    {
        List<Bans> Banea2;
        public BanList()
        {
            Banea2 = DBconnection.Instance.GetBans();
        }
        public Bans GetBan(string User)
        {
            return DBconnection.Instance.GetBan(User);
        }
        public void updateBan()
        {
            foreach (var baned in Banea2)
            {
                if ((baned.FechaExpiracion - DateTime.Now).TotalHours <= 1)
                {
                    removeBan(baned);
                }
            }
        }
        public bool Banear(string User,string Admin)
        {
            return DBconnection.Instance.Ban(User, DBconnection.Instance.getAdminId(Admin));
        }

        private void removeBan(Bans baned)
        {
            DBconnection.Instance.DeleteBan(baned.idBans);
        }
    }
}